<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: drogon::WebSocketConnection类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacedrogon.html">drogon</a></li><li class="navelem"><a class="el" href="classdrogon_1_1WebSocketConnection.html">WebSocketConnection</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="classdrogon_1_1WebSocketConnection-members.html">所有成员列表</a>  </div>
  <div class="headertitle"><div class="title">drogon::WebSocketConnection类 参考<span class="mlabels"><span class="mlabel">abstract</span></span></div></div>
</div><!--header-->
<div class="contents">

<p>The WebSocket connection abstract class.  
 <a href="classdrogon_1_1WebSocketConnection.html#details">更多...</a></p>

<p><code>#include &lt;<a class="el" href="WebSocketConnection_8h_source.html">WebSocketConnection.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:a3ea9882baad127a8fee5309800415e86" id="r_a3ea9882baad127a8fee5309800415e86"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a3ea9882baad127a8fee5309800415e86">WebSocketConnection</a> ()=default</td></tr>
<tr class="separator:a3ea9882baad127a8fee5309800415e86"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae1498047678574801a8de8bc0c7028f6" id="r_ae1498047678574801a8de8bc0c7028f6"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#ae1498047678574801a8de8bc0c7028f6">~WebSocketConnection</a> ()</td></tr>
<tr class="separator:ae1498047678574801a8de8bc0c7028f6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab4d7fa899a69d14c5705c70b1eed1f2b" id="r_ab4d7fa899a69d14c5705c70b1eed1f2b"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#ab4d7fa899a69d14c5705c70b1eed1f2b">send</a> (const char *msg, uint64_t len, const <a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a> type=<a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8a9dffbf69ffba8bc38bc4e01abf4b1675">WebSocketMessageType::Text</a>)=0</td></tr>
<tr class="memdesc:ab4d7fa899a69d14c5705c70b1eed1f2b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Send a message to the peer  <br /></td></tr>
<tr class="separator:ab4d7fa899a69d14c5705c70b1eed1f2b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6a2208cb031ad11cc59ac12cdbb3c5b8" id="r_a6a2208cb031ad11cc59ac12cdbb3c5b8"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a6a2208cb031ad11cc59ac12cdbb3c5b8">send</a> (std::string_view msg, const <a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a> type=<a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8a9dffbf69ffba8bc38bc4e01abf4b1675">WebSocketMessageType::Text</a>)=0</td></tr>
<tr class="memdesc:a6a2208cb031ad11cc59ac12cdbb3c5b8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Send a message to the peer  <br /></td></tr>
<tr class="separator:a6a2208cb031ad11cc59ac12cdbb3c5b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a068db7c076e16cdee081aecae6c0e38e" id="r_a068db7c076e16cdee081aecae6c0e38e"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a068db7c076e16cdee081aecae6c0e38e">sendJson</a> (const Json::Value &amp;json, const <a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a> type=<a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8a9dffbf69ffba8bc38bc4e01abf4b1675">WebSocketMessageType::Text</a>)=0</td></tr>
<tr class="memdesc:a068db7c076e16cdee081aecae6c0e38e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Send a message to the peer  <br /></td></tr>
<tr class="separator:a068db7c076e16cdee081aecae6c0e38e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adf1374a1f2ef676bffd794af75cf262d" id="r_adf1374a1f2ef676bffd794af75cf262d"><td class="memItemLeft" align="right" valign="top">virtual const trantor::InetAddress &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#adf1374a1f2ef676bffd794af75cf262d">localAddr</a> () const =0</td></tr>
<tr class="memdesc:adf1374a1f2ef676bffd794af75cf262d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the local IP address and port number of the connection  <br /></td></tr>
<tr class="separator:adf1374a1f2ef676bffd794af75cf262d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a842b28c425db0ffe844f16afa5a999eb" id="r_a842b28c425db0ffe844f16afa5a999eb"><td class="memItemLeft" align="right" valign="top">virtual const trantor::InetAddress &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a842b28c425db0ffe844f16afa5a999eb">peerAddr</a> () const =0</td></tr>
<tr class="memdesc:a842b28c425db0ffe844f16afa5a999eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the remote IP address and port number of the connection  <br /></td></tr>
<tr class="separator:a842b28c425db0ffe844f16afa5a999eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa97345346483459ad520ed8fccdb21ac" id="r_aa97345346483459ad520ed8fccdb21ac"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#aa97345346483459ad520ed8fccdb21ac">connected</a> () const =0</td></tr>
<tr class="memdesc:aa97345346483459ad520ed8fccdb21ac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return true if the connection is open  <br /></td></tr>
<tr class="separator:aa97345346483459ad520ed8fccdb21ac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ada8616e96b90a5e3b12bbc29266c7d3d" id="r_ada8616e96b90a5e3b12bbc29266c7d3d"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#ada8616e96b90a5e3b12bbc29266c7d3d">disconnected</a> () const =0</td></tr>
<tr class="memdesc:ada8616e96b90a5e3b12bbc29266c7d3d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return true if the connection is closed  <br /></td></tr>
<tr class="separator:ada8616e96b90a5e3b12bbc29266c7d3d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0a95cfa8e061aa94436fb2f217e4e1eb" id="r_a0a95cfa8e061aa94436fb2f217e4e1eb"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a0a95cfa8e061aa94436fb2f217e4e1eb">shutdown</a> (const <a class="el" href="namespacedrogon.html#a3d8870fa55561abeaf9aaceb8f465d0d">CloseCode</a> code=<a class="el" href="namespacedrogon.html#a3d8870fa55561abeaf9aaceb8f465d0daf25231f601cbfeb994d10ebd31da93c0">CloseCode::kNormalClosure</a>, const std::string &amp;reason=&quot;&quot;)=0</td></tr>
<tr class="memdesc:a0a95cfa8e061aa94436fb2f217e4e1eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Shut down the write direction, which means that further send operations are disabled.  <br /></td></tr>
<tr class="separator:a0a95cfa8e061aa94436fb2f217e4e1eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abdaebe4ad76827244e39c46be9992eb4" id="r_abdaebe4ad76827244e39c46be9992eb4"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#abdaebe4ad76827244e39c46be9992eb4">forceClose</a> ()=0</td></tr>
<tr class="memdesc:abdaebe4ad76827244e39c46be9992eb4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Close the connection  <br /></td></tr>
<tr class="separator:abdaebe4ad76827244e39c46be9992eb4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3cae4475ea82225e893229bd2cf31105" id="r_a3cae4475ea82225e893229bd2cf31105"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a3cae4475ea82225e893229bd2cf31105">setContext</a> (const std::shared_ptr&lt; void &gt; &amp;context)</td></tr>
<tr class="memdesc:a3cae4475ea82225e893229bd2cf31105"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set custom data on the connection  <br /></td></tr>
<tr class="separator:a3cae4475ea82225e893229bd2cf31105"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a23e95a9abccdda9a1fbaa7aff81d30ef" id="r_a23e95a9abccdda9a1fbaa7aff81d30ef"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a23e95a9abccdda9a1fbaa7aff81d30ef">setContext</a> (std::shared_ptr&lt; void &gt; &amp;&amp;context)</td></tr>
<tr class="memdesc:a23e95a9abccdda9a1fbaa7aff81d30ef"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set custom data on the connection  <br /></td></tr>
<tr class="separator:a23e95a9abccdda9a1fbaa7aff81d30ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad1f9c4a52807041d7087d61c713b960d" id="r_ad1f9c4a52807041d7087d61c713b960d"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ad1f9c4a52807041d7087d61c713b960d"><td class="memTemplItemLeft" align="right" valign="top">std::shared_ptr&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#ad1f9c4a52807041d7087d61c713b960d">getContext</a> () const</td></tr>
<tr class="memdesc:ad1f9c4a52807041d7087d61c713b960d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get custom data from the connection  <br /></td></tr>
<tr class="separator:ad1f9c4a52807041d7087d61c713b960d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1e28b3411ec3f64f72bbc1115c0022f3" id="r_a1e28b3411ec3f64f72bbc1115c0022f3"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a1e28b3411ec3f64f72bbc1115c0022f3"><td class="memTemplItemLeft" align="right" valign="top">T &amp;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a1e28b3411ec3f64f72bbc1115c0022f3">getContextRef</a> () const</td></tr>
<tr class="memdesc:a1e28b3411ec3f64f72bbc1115c0022f3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the custom data reference from the connection.  <br /></td></tr>
<tr class="separator:a1e28b3411ec3f64f72bbc1115c0022f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6927796c7cdc757ebefdbbcd1101d638" id="r_a6927796c7cdc757ebefdbbcd1101d638"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a6927796c7cdc757ebefdbbcd1101d638">hasContext</a> ()</td></tr>
<tr class="memdesc:a6927796c7cdc757ebefdbbcd1101d638"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return true if the context is set by user.  <br /></td></tr>
<tr class="separator:a6927796c7cdc757ebefdbbcd1101d638"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5106f9cab32766a2761e58fad73eacd1" id="r_a5106f9cab32766a2761e58fad73eacd1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a5106f9cab32766a2761e58fad73eacd1">clearContext</a> ()</td></tr>
<tr class="memdesc:a5106f9cab32766a2761e58fad73eacd1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clear the context.  <br /></td></tr>
<tr class="separator:a5106f9cab32766a2761e58fad73eacd1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5c4815b05f8cbafe3ae1f1967c831b1b" id="r_a5c4815b05f8cbafe3ae1f1967c831b1b"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a5c4815b05f8cbafe3ae1f1967c831b1b">setPingMessage</a> (const std::string &amp;message, const std::chrono::duration&lt; double &gt; &amp;interval)=0</td></tr>
<tr class="memdesc:a5c4815b05f8cbafe3ae1f1967c831b1b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the heartbeat(ping) message sent to the peer.  <br /></td></tr>
<tr class="separator:a5c4815b05f8cbafe3ae1f1967c831b1b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9477289404894c6ed4d434518f82ab9e" id="r_a9477289404894c6ed4d434518f82ab9e"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1WebSocketConnection.html#a9477289404894c6ed4d434518f82ab9e">disablePing</a> ()=0</td></tr>
<tr class="memdesc:a9477289404894c6ed4d434518f82ab9e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Disable sending ping messages to the peer.  <br /></td></tr>
<tr class="separator:a9477289404894c6ed4d434518f82ab9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p>The WebSocket connection abstract class. </p>
</div><h2 class="groupheader">构造及析构函数说明</h2>
<a id="a3ea9882baad127a8fee5309800415e86" name="a3ea9882baad127a8fee5309800415e86"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3ea9882baad127a8fee5309800415e86">&#9670;&#160;</a></span>WebSocketConnection()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">drogon::WebSocketConnection::WebSocketConnection </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">default</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<a id="ae1498047678574801a8de8bc0c7028f6" name="ae1498047678574801a8de8bc0c7028f6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae1498047678574801a8de8bc0c7028f6">&#9670;&#160;</a></span>~WebSocketConnection()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual drogon::WebSocketConnection::~WebSocketConnection </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">成员函数说明</h2>
<a id="a5106f9cab32766a2761e58fad73eacd1" name="a5106f9cab32766a2761e58fad73eacd1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5106f9cab32766a2761e58fad73eacd1">&#9670;&#160;</a></span>clearContext()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void drogon::WebSocketConnection::clearContext </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Clear the context. </p>

</div>
</div>
<a id="aa97345346483459ad520ed8fccdb21ac" name="aa97345346483459ad520ed8fccdb21ac"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa97345346483459ad520ed8fccdb21ac">&#9670;&#160;</a></span>connected()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool drogon::WebSocketConnection::connected </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return true if the connection is open </p>

</div>
</div>
<a id="a9477289404894c6ed4d434518f82ab9e" name="a9477289404894c6ed4d434518f82ab9e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9477289404894c6ed4d434518f82ab9e">&#9670;&#160;</a></span>disablePing()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void drogon::WebSocketConnection::disablePing </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Disable sending ping messages to the peer. </p>

</div>
</div>
<a id="ada8616e96b90a5e3b12bbc29266c7d3d" name="ada8616e96b90a5e3b12bbc29266c7d3d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ada8616e96b90a5e3b12bbc29266c7d3d">&#9670;&#160;</a></span>disconnected()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool drogon::WebSocketConnection::disconnected </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return true if the connection is closed </p>

</div>
</div>
<a id="abdaebe4ad76827244e39c46be9992eb4" name="abdaebe4ad76827244e39c46be9992eb4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abdaebe4ad76827244e39c46be9992eb4">&#9670;&#160;</a></span>forceClose()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void drogon::WebSocketConnection::forceClose </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Close the connection </p>

</div>
</div>
<a id="ad1f9c4a52807041d7087d61c713b960d" name="ad1f9c4a52807041d7087d61c713b960d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad1f9c4a52807041d7087d61c713b960d">&#9670;&#160;</a></span>getContext()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::shared_ptr&lt; T &gt; drogon::WebSocketConnection::getContext </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get custom data from the connection </p>
<dl class="tparams"><dt>模板参数</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T</td><td>The type of the data </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>std::shared_ptr&lt;T&gt; The smart pointer to the data object. </dd></dl>

</div>
</div>
<a id="a1e28b3411ec3f64f72bbc1115c0022f3" name="a1e28b3411ec3f64f72bbc1115c0022f3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1e28b3411ec3f64f72bbc1115c0022f3">&#9670;&#160;</a></span>getContextRef()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T &amp; drogon::WebSocketConnection::getContextRef </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get the custom data reference from the connection. </p>
<dl class="section note"><dt>注解</dt><dd>Please make sure that the context is available. </dd></dl>
<dl class="tparams"><dt>模板参数</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T</td><td>The type of the data stored in the context. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>T&amp; </dd></dl>

</div>
</div>
<a id="a6927796c7cdc757ebefdbbcd1101d638" name="a6927796c7cdc757ebefdbbcd1101d638"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6927796c7cdc757ebefdbbcd1101d638">&#9670;&#160;</a></span>hasContext()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool drogon::WebSocketConnection::hasContext </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return true if the context is set by user. </p>

</div>
</div>
<a id="adf1374a1f2ef676bffd794af75cf262d" name="adf1374a1f2ef676bffd794af75cf262d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adf1374a1f2ef676bffd794af75cf262d">&#9670;&#160;</a></span>localAddr()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual const trantor::InetAddress &amp; drogon::WebSocketConnection::localAddr </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the local IP address and port number of the connection </p>

</div>
</div>
<a id="a842b28c425db0ffe844f16afa5a999eb" name="a842b28c425db0ffe844f16afa5a999eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a842b28c425db0ffe844f16afa5a999eb">&#9670;&#160;</a></span>peerAddr()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual const trantor::InetAddress &amp; drogon::WebSocketConnection::peerAddr </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the remote IP address and port number of the connection </p>

</div>
</div>
<a id="ab4d7fa899a69d14c5705c70b1eed1f2b" name="ab4d7fa899a69d14c5705c70b1eed1f2b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab4d7fa899a69d14c5705c70b1eed1f2b">&#9670;&#160;</a></span>send() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void drogon::WebSocketConnection::send </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint64_t&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a>&#160;</td>
          <td class="paramname"><em>type</em> = <code><a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8a9dffbf69ffba8bc38bc4e01abf4b1675">WebSocketMessageType::Text</a></code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Send a message to the peer </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">msg</td><td>The message to be sent. </td></tr>
    <tr><td class="paramname">len</td><td>The message length. </td></tr>
    <tr><td class="paramname">type</td><td>The message type. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a6a2208cb031ad11cc59ac12cdbb3c5b8" name="a6a2208cb031ad11cc59ac12cdbb3c5b8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6a2208cb031ad11cc59ac12cdbb3c5b8">&#9670;&#160;</a></span>send() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void drogon::WebSocketConnection::send </td>
          <td>(</td>
          <td class="paramtype">std::string_view&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a>&#160;</td>
          <td class="paramname"><em>type</em> = <code><a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8a9dffbf69ffba8bc38bc4e01abf4b1675">WebSocketMessageType::Text</a></code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Send a message to the peer </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">msg</td><td>The message to be sent. </td></tr>
    <tr><td class="paramname">type</td><td>The message type. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a068db7c076e16cdee081aecae6c0e38e" name="a068db7c076e16cdee081aecae6c0e38e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a068db7c076e16cdee081aecae6c0e38e">&#9670;&#160;</a></span>sendJson()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void drogon::WebSocketConnection::sendJson </td>
          <td>(</td>
          <td class="paramtype">const Json::Value &amp;&#160;</td>
          <td class="paramname"><em>json</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8">WebSocketMessageType</a>&#160;</td>
          <td class="paramname"><em>type</em> = <code><a class="el" href="namespacedrogon.html#a60c960a4500d47d200b72356dfcd06e8a9dffbf69ffba8bc38bc4e01abf4b1675">WebSocketMessageType::Text</a></code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Send a message to the peer </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">json</td><td>The JSON message to be sent. </td></tr>
    <tr><td class="paramname">type</td><td>The message type. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a3cae4475ea82225e893229bd2cf31105" name="a3cae4475ea82225e893229bd2cf31105"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3cae4475ea82225e893229bd2cf31105">&#9670;&#160;</a></span>setContext() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void drogon::WebSocketConnection::setContext </td>
          <td>(</td>
          <td class="paramtype">const std::shared_ptr&lt; void &gt; &amp;&#160;</td>
          <td class="paramname"><em>context</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Set custom data on the connection </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">context</td><td>The custom data. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a23e95a9abccdda9a1fbaa7aff81d30ef" name="a23e95a9abccdda9a1fbaa7aff81d30ef"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a23e95a9abccdda9a1fbaa7aff81d30ef">&#9670;&#160;</a></span>setContext() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void drogon::WebSocketConnection::setContext </td>
          <td>(</td>
          <td class="paramtype">std::shared_ptr&lt; void &gt; &amp;&amp;&#160;</td>
          <td class="paramname"><em>context</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Set custom data on the connection </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">context</td><td>The custom data. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a5c4815b05f8cbafe3ae1f1967c831b1b" name="a5c4815b05f8cbafe3ae1f1967c831b1b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5c4815b05f8cbafe3ae1f1967c831b1b">&#9670;&#160;</a></span>setPingMessage()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void drogon::WebSocketConnection::setPingMessage </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>message</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const std::chrono::duration&lt; double &gt; &amp;&#160;</td>
          <td class="paramname"><em>interval</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Set the heartbeat(ping) message sent to the peer. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">message</td><td>The ping message. </td></tr>
    <tr><td class="paramname">interval</td><td>The sending interval. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>注解</dt><dd>Both the server and the client in Drogon automatically send the pong message after receiving the ping message. An empty ping message is sent every 30 seconds by default. The method overrides the default behavior. </dd></dl>

</div>
</div>
<a id="a0a95cfa8e061aa94436fb2f217e4e1eb" name="a0a95cfa8e061aa94436fb2f217e4e1eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0a95cfa8e061aa94436fb2f217e4e1eb">&#9670;&#160;</a></span>shutdown()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void drogon::WebSocketConnection::shutdown </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="namespacedrogon.html#a3d8870fa55561abeaf9aaceb8f465d0d">CloseCode</a>&#160;</td>
          <td class="paramname"><em>code</em> = <code><a class="el" href="namespacedrogon.html#a3d8870fa55561abeaf9aaceb8f465d0daf25231f601cbfeb994d10ebd31da93c0">CloseCode::kNormalClosure</a></code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>reason</em> = <code>&quot;&quot;</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Shut down the write direction, which means that further send operations are disabled. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">code</td><td>Please refer to the enum class CloseCode. (RFC6455 7.4.1) </td></tr>
    <tr><td class="paramname">reason</td><td>The reason for closing the connection. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li><a class="el" href="WebSocketConnection_8h_source.html">WebSocketConnection.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
